//
//  RadioView.m
//  WWXELuShang
//
//  Created by lanou on 15/12/19.
//  Copyright © 2015年 lanou. All rights reserved.
//

#import "RadioView.h"
#import "Radio.h"

@implementation RadioView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.pictureView = [[UIImageView alloc]initWithFrame:CGRectMake(kWidth / 12, kHeight / 8, kWidth / 1.2, kWidth / 1.2)];
        self.pictureView.layer.masksToBounds = YES;
        //边角颜色
        self.pictureView.layer.borderColor = [[UIColor whiteColor]CGColor];
        self.pictureView.layer.borderWidth = 2.0;
        self.pictureView.layer.cornerRadius = self.pictureView.bounds.size.height / 2;
        self.pictureView.image = [UIImage imageNamed:@"ic_blank_collect@3x"];
        
        [self addSubview:self.pictureView];
        
        
        self.playButton = [UIButton buttonWithType:(UIButtonTypeSystem)];
//        self.playButton.frame = CGRectMake(kWidth /2.38, kHeight /1.22, kWidth/6.25 ,kWidth/6.25 );
        self.playButton.frame = CGRectMake(kWidth /2.38, kHeight /1.15, kWidth/6.25 ,kWidth/6.25 );
        
        if ([Radio shareWithRadio].isReadyToPlay == YES) {
            [self.playButton setImage:[UIImage imageNamed:@"player_pause"] forState:(UIControlStateNormal)];
        }else{
            [self.playButton setImage:[UIImage imageNamed:@"player_play@2x"] forState:(UIControlStateNormal)];
        }
        
        [self setTintColor:[UIColor whiteColor]];
        [self addSubview:self.playButton];
        
        
        self.detailsButton = [UIButton buttonWithType:(UIButtonTypeSystem)];
        self.detailsButton.frame = CGRectMake(kWidth /6, kHeight /1.15, 60, 60);
        [self.detailsButton setImage:[UIImage imageNamed:@"icon_menu_highlight@2x"] forState:(UIControlStateNormal)];
        [self setTintColor:[UIColor whiteColor]];
        [self addSubview:self.detailsButton];
        
        self.albumLabel = [[UILabel alloc]initWithFrame:CGRectMake(0,0, 200, 30)];
        self.albumLabel.center = CGPointMake(kWidth/2, CGRectGetMaxY(self.pictureView.frame) + kHeight /15);
        self.albumLabel.textColor = [UIColor whiteColor];
        self.albumLabel.textAlignment = NSTextAlignmentCenter;

        [self addSubview:self.albumLabel];
        
        
        self.programtimeLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 200, 30)];
        self.programtimeLabel.center = CGPointMake(kWidth/2, CGRectGetMaxY(self.pictureView.frame) + kHeight /6);
        self.programtimeLabel.textColor = [UIColor whiteColor];
        self.programtimeLabel.textAlignment = NSTextAlignmentCenter;
        [self addSubview:self.programtimeLabel];
        
        
//        NSString* phoneModel = [[UIDevice currentDevice] model];
//        NSLog(@"手机型号: %@",phoneModel );
        
//        NSString* deviceName = [[UIDevice currentDevice] systemName];
//        NSLog(@"设备名称: %@",deviceName );
        
       
        self.barrageButton = [UIButton buttonWithType:(UIButtonTypeSystem)];
//        self.barrageButton.frame = CGRectMake(kWidth /1.43, kHeight /1.205, 50, 50);
        self.barrageButton.frame = CGRectMake(kWidth /1.43, kHeight /1.14, 50, 50);
        
//        if ([Radio shareWithRadio].isReadyToBarrage == YES) {
//            [self.barrageButton setImage:[UIImage imageNamed:@"barrage1"] forState:(UIControlStateNormal)];
//        }else{
//            UIImage *buttonImage = [UIImage imageNamed:@"barrage1"];
//            buttonImage = [buttonImage imageWithRenderingMode:(UIImageRenderingModeAlwaysOriginal)];
//            [self.barrageButton setImage:buttonImage forState:(UIControlStateNormal)];
//        }
        
        
        
        
        
        [self addSubview:self.barrageButton];
        
        
        
        
        
    }
    return self;
}













/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
